import 'package:flutter/services.dart';

class Bluetoothcontroller {
  static const MethodChannel _channel =
      const MethodChannel('my.flutter.io/bluetooth');

  static void connectDevice(Map<String,Object> dataMap)  {
    _channel.invokeMethod('connectDevice',dataMap).then((value){print(value);});//调用底层去连接蓝牙设备
  }

  static void applyBlueAuth() {
    _channel.invokeMethod('applyBlueAuth').then((value){print(value);});//调用底层去申請藍牙權限
  }

  static void sendData(Map<String,Object> dataMap) {
    _channel.invokeMethod('sendData',dataMap).then((value){print(value);});//调用底层去向藍牙設備發送數據
  }

  static void disConnectDevice(String deviceName) {
    _channel.invokeMethod('disConnectDevice',deviceName).then((value){print(value);});//调用底层去跟藍牙設備斷開連接
  }
}
